<?php
class shopAdminBase extends Activity {
    /** @var CmsView  */
    protected $cms;
    /** @var  UserModule */
    protected $user;
    /** @var  array */
    protected $shopInfo;
    function __construct() {
        $this->user=UserModule::init("user");
        if(!$this->user->checkLogin()){
            $_SESSION['user_login_call_back']=$_SERVER['REQUEST_URI'];
            header("Location:".WebRouter::init()->getAbsolute("user/login"));
            exit();
        }
        $userInfo=$this->user->getLoginInfo();
        if($userInfo['type']!='shop'&&$userInfo['type']!='both'){
            $re['message']="您不是商家，无法进入商家后台";
            $re['url']=WebRouter::init()->getAbsolute("");
            View::displayAsHtml($re, 'plugin/state/tips.php');
            exit();
        }
        $shopMode=ShopMode::init();
        $this->shopInfo=$shopMode->getDetail($shopMode->getShopId($userInfo['id']));
        if($this->shopInfo['enable']==0){
            $re['message']="商家申请暂未审核，无法进入商家后台，请耐心等待";
            $re['url']=WebRouter::init()->getAbsolute("");
            View::displayAsHtml($re, 'plugin/state/tips.php');
            exit();
        }
        $this->cms=CmsView::init(null, null, array(
            "navFile"=>"shop/nav.json",
            "userInfoFile"=>"shop/userinfo.json",
            "controlFile"=>"",
        ));
        $this->cms->setUserName($this->shopInfo['company']);
    }
}
